package carclockpack;

import java.util.*;

public class HourSetupState implements ClockSetupState {
    private ClockSetup clockSetup;
    private int hour;
 
    public HourSetupState(ClockSetup clockSetup) {
        this.clockSetup = clockSetup;
        hour = Calendar.getInstance().get(Calendar.HOUR);
    }
 
    public void previousValue() {
        if (hour > 0) {
            hour--;
        }
    }
 
    public void nextValue() {
        if (hour < 23) {
            hour++;
        }
    }
 
    public void selectValue() {
        System.out.println("Hour set to " + hour);
        clockSetup.setState(clockSetup.getMinuteSetupState());
    }
 
    public String getInstructions() {
        return "Please set the hour...";
    }
 
    public int getSelectedValue() {
        return hour;
    }
}